package com.z.xviewpager;

import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.z.xviewpager.xviewpager.XViewPager;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        final XViewPager xViewPager = (XViewPager) findViewById(R.id.xvp);
        List<String> data = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            data.add("Item " + i);
        }
        TestAdapter adapter = new TestAdapter(data);
        xViewPager.setOnPageChangeListener(new XViewPager.OnPageChangeListener() {
            @Override
            public void onPageChange(int position) {
                Log.i("xViewPager", "position = " + position);
            }
        });
        xViewPager.setAdapter(adapter);

        xViewPager.setCurrentItem(2);



        Button button = (Button) findViewById(R.id.bt);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                xViewPager.scrollToPreviousView();
            }
        });




        ViewPager viewPager = new ViewPager(this);
        //viewPager.setCurrentItem();


    }
}
